<?php
/**
 *  @author wyl
 *  @date 2015-9-18 15:27:42
 */
Yii::import('application.components.bid.*');
ignore_user_abort(true);
class TestBidCommand extends CConsoleCommand{
	public function run($args){
 		while ($args[0]>time()){};
 		$bid=new BidDao();
 		$bid->setCustomerId(3)->cost(10, 'CASH', 'BID_AUCTION')->earn(5, 'CASH', 'BID_AUCTION')->run();
 		/* foreach ($bid->getList() as $l){
 			var_dump($l->attributes);
 		} */
		//var_dump('hahaha');
		//while ($args[0]>time()){};
		/* $f=fopen(Yii::app()->basePath.'/components/bid/locks/lock.lock','a+');
		var_dump(Yii::app()->basePath.'/components/bid/locks/lock.lock');
		var_dump($f);
		$l=flock($f,LOCK_EX);
		var_dump($l);
		if($l){
			fwrite($f,'lock');
			sleep(20);
			flock($f,LOCK_UN);
		}
		fclose($f); */
		
		
		// a.php
		/*
		if ( ! ($f = @fopen("flock.log","ab"))) exit;
		flock($f, LOCK_EX);
		while(TRUE)
		{
			fwrite($f, "a\n");
		}
		*/
		
		
		//fwrite($fp, "Write something here\n");
		
		/*
		if (flock($fp, LOCK_EX)) {  // 进行排它型锁定
			fwrite($fp, "Write something here\n");						
			fflush($fp);            // flush output before releasing the lock
			flock($fp, LOCK_UN);    // 释放锁定
		} else {
			echo "Couldn't get the lock!";
		}
		
		fclose($fp);
		*/
		/* $r=new Redis();
		$r->connect('127.0.0.1',6379);
		$result=$r->sAdd('wlvgfe','lock');
		if($result){
			file_put_contents(Yii::app()->basePath.'/components/bid/locks/1234.lock','lock',FILE_APPEND);
			sleep(1);
			$r->sRemove('wlvgfe','lock');
		} */
	}
}
